<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        /* 方法一： 弹性盒 */
        /* html{
            height: 100%
        }
        body{
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        #son{
            height: 100px;
            width: 100px;
            background-color: aqua;
        } */

        /* 方法二： 定位+margin */
        /* html{
            height: 100%
        }
        body{
            height: 100%;
            position: relative;
        }
        #son{
            height: 100px;
            width: 100px;
            background-color: aqua;
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -50px;
            margin-left: -50px;
        } */

        /* 方法三： 定位+ translate */
        /* html{
            height: 100%
        }
        body{
            height: 100%;
            position: relative;
        }
        #son{
            height: 100px;
            width: 100px;
            background-color: aqua;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
        } */

        /* 方法四： 定位+ margn auto */
        html{
            height: 100%
        }
        body{
            height: 100%;
            position: relative;
        }
        #son{
            height: 100px;
            width: 100px;
            background-color: aqua;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
        }

    </style>
</head>
<body>
        <div id="son"></div>

</body>
</html>

<!-- 四种方法都应该掌握 -->